Skip to content

perf: further improve performance of ElementAwareArrayList#2373

Merged
triceo merged 12 commits into
TimefoldAI:mainfrom
triceo:eaal
Jun 19, 2026
Merged

perf: further improve performance of ElementAwareArrayList#2373
triceo merged 12 commits into
TimefoldAI:mainfrom
triceo:eaal

Conversation

@triceo

@triceo triceo commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

The goal here is to minimize the overhead of add/remove methods, as they showed up the highest in profiling in comparison to the original ElementAwareLinkedList.

Copilot AI review requested due to automatic review settings June 15, 2026 05:04
@triceo triceo requested a review from zepfred as a code owner June 15, 2026 05:04
@triceo triceo added this to the v2.3.0 milestone Jun 15, 2026
@triceo triceo self-assigned this Jun 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues performance-focused work by optimizing ElementAwareArrayList internals (gap tracking/compaction and backing-array retention), refining tabu acceptor behavior (including deterministic fading-taboo decisions), and simplifying Bavet leaf indexing by removing the linked-list backend.

Changes:

  • Reworked ElementAwareArrayList to avoid fail-fast iteration/modCount overhead, add compact() + firstGapPosition fast paths, and free large backing arrays when the list becomes empty.
  • Updated tabu acceptors to use a new fading-taboo decision path with deterministic random consumption behavior; tightened configuration validation and tabu size constraints.
  • Removed LinkedListLeafIndexer and switched indexer construction/tests to RandomAccessLeafIndexer.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/src/main/java/ai/timefold/solver/core/impl/util/ElementAwareArrayList.java Optimizes gap handling/compaction, iterator behavior, and backing array retention/freeing.
core/src/test/java/ai/timefold/solver/core/impl/util/ElementAwareArrayListTest.java Adds tests for compaction/first-gap behavior and backing-array free-path; adds randomized stress test.
core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/AbstractTabuAcceptor.java Refactors fading-taboo acceptance into a decision helper that can avoid consuming random in certain outcomes.
core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/size/FixedTabuSizeStrategy.java Enforces tabu size must be at least 1 and improves exception message.
core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/size/FixedTabuSizeStrategyTest.java Adds test coverage for invalid tabu sizes (0 and negative).
core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/AcceptorFactory.java Improves error messages, validates tabu acceptor configs, and removes duplicated configuration code.
core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/AcceptorFactoryTest.java Verifies factory rejects tabu acceptors without configured sizes.
core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/ValueTabuAcceptorTest.java Adds fading-taboo behavior test using deterministic TestRandom.
core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/EntityTabuAcceptorTest.java Adds fading-taboo behavior test using deterministic TestRandom.
core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/MoveTabuAcceptorTest.java Introduces move-taboo tests, including fading-taboo and aspiration scenarios.
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/LinkedListLeafIndexer.java Removed linked-list leaf backend implementation.
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/LeafIndexer.java Updates sealed permits to remove the deleted linked-list backend.
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/IndexerFactory.java Switches indexer backend creation to always use RandomAccessLeafIndexer.
core/src/test/java/ai/timefold/solver/core/impl/bavet/common/index/FusedEqualIndexTest.java Updates fused equal index test to use RandomAccessLeafIndexer.

@zepfred zepfred left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I have a few minor comments and some questions.

Copilot AI review requested due to automatic review settings June 19, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

This reverts commit 9ba4ff6.
Copilot AI review requested due to automatic review settings June 19, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread .mvn/maven.config
@sonarqubecloud

Copy link
Copy Markdown

@triceo triceo merged commit 9adba5a into TimefoldAI:main Jun 19, 2026
18 checks passed
@triceo triceo deleted the eaal branch June 19, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants